<?php
//
//  VictoryCMS - Content managment system and framework.
//  Copyright (C) 2009  Lewis Gunsch
//
//  This file is part of VictoryCMS.
//  
//  VictoryCMS is free software: you can redistribute it and/or modify
//  it under the terms of the GNU General Public License as published by
//  the Free Software Foundation, either version 3 of the License, or
//  (at your option) any later version.
//
//  VictoryCMS is distributed in the hope that it will be useful,
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//  GNU General Public License for more details.
//  
//  You should have received a copy of the GNU General Public License
//  along with VictoryCMS.  If not, see <http://www.gnu.org/licenses/>.

/**
 * VictoryCMS - PageListing
 * 
 * @license http://www.gnu.org/licenses/gpl.html
 * @author Lewis Gunsch
 * @filesource
 * @package DisplayablePages
 */

/**
 * Lists all available DisplayablePages.
 * 
 * @package DisplayablePages
 */
class PageListing implements DisplayablePage {

	/** @see DisplayablePage#getTitle() */
	public function getTitle() {
		return "Page Listing";
	}

	/** @see DisplayablePage#getName() */
	public function getName() {
		return "Displayable Page Listing";
	}

	/** @see DisplayablePage#getDescription() */
	public function getDescription() {
		return "Lists all the available DisplayablePage's.";
	}

	/** @see DisplayablePage#getKeywords() */
	public function getKeywords() {
		return "";
	}

	/** @see DisplayablePage#getHeaderInfo() */
	public function getHeaderInfo() {
		return "";
	}

	/** @see DisplayablePage#renderPage() */
	public function renderPage( $currentPage ) {
		$html = "<h4>Available DisplayablePages:</h4>";
		$html .= "<ul style=\"\">";
		$pages = PageFactory::listDisplayablePages();
		foreach ($pages as $pageName) {
			$pageClass = PageFactory::createDisplayablePage($pageName);
			$html .= "<li><a href='/index.php?page=$pageName'>". $pageClass->getName() ."</a>";
			$html .= "&nbsp;-&nbsp;". $pageClass->getDescription() ."</li>\n";
		}
		$html .= "</ul>";
		
		return $html;
	}

	/** @see DisplayablePage#pagePreProcess() */
	public function pagePreProcess() {
		return;
	}

	/** @see DisplayablePage#getPagePermissionLevel() */
	public function getPagePermissionLevel() {
		return new Permission("anonymous");
	}
}
?>